package com.leo.controller;

import com.leo.service.UserInfoService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.servlet.ModelAndView;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.util.List;

/**
 * @ClassName: GetUserInfoController
 * @Description: ${description}
 * @Author: leo825
 * @Date: 2020-01-02 15:34
 * @Version: 1.0
 */
@Controller
public class GetUserInfoController {

    @Autowired
    UserInfoService userInfoService;

    @RequestMapping("/getUserInfoList1")
    public ModelAndView getUserInfoList1(HttpServletRequest httpServletRequest, HttpServletResponse httpServletResponse) throws Exception {
        System.out.println("GetUserInfoController获取用户信息");
        ModelAndView modelAndView = new ModelAndView();
        //访问数据库
        List userInfoList = userInfoService.getUserInfoList();
        System.out.println(userInfoList);
        modelAndView.addObject("data", userInfoList);
        modelAndView.setViewName("success");//跳转到/WEB-INF/views/success.jsp
        System.out.println("getUserInfoList1执行结束，开始返回");
        return modelAndView;
    }
}
